﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Rotempco.Website.Logic;
using Rotempco.Core.Web.CRUD.Objects;
using Rotempco.Core.Web.CRUD.Interfaces;
using Rotempco.Core.Web.Logic;

namespace Rotempco.Website.MasterPages
{
    public partial class CRUDDefault : System.Web.UI.MasterPage, ICRUDDefault
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (UrlLogic.AspxFileExist("Edit.aspx"))
                hyperLink_New.NavigateUrl = UrlLogic.GotoUrl(url: UrlLogic.GetStaticBaseUrl() + "/Edit.aspx");
            else
                placeholder_New.Visible = false;

            if (UrlLogic.AspxFileExist("ImportFile.aspx"))
                hyperLink_ImportFile.NavigateUrl = UrlLogic.GotoUrl(url: UrlLogic.GetStaticBaseUrl() + "/ImportFile.aspx");
            else
                placeholder_ImportFile.Visible = false;

            if (UrlLogic.AspxFileExist("Restore.aspx"))
                hyperLink_Restore.NavigateUrl = UrlLogic.GotoUrl(url: UrlLogic.GetStaticBaseUrl() + "/Restore.aspx");
            else
                placeHolder_Restore.Visible = false;
        }

        public void HideNewButton()
        {
            placeholder_New.Visible = false;
        }

        public void SetDefaultPageContainer(PageListContainer detailPageContainer)
        {
            DetailsList.SetDetailsList(detailPageContainer);
        }
    }
}